package cn.gem.rainbow.cfg.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Order(2)
public class CustomAspect {
    //前置通知
    @Before("@annotation(test)")
    // 拦截被TestAnnotation注解的方法；如果你需要拦截指定package指定规则名称的方法，可以使用表达式execution(...)，具体百度一下资料一大堆
    public void beforeTest(JoinPoint point, CustomAnnotation test) throws Throwable {
        System.out.println("----order=2------beforeTest:" + test.name());
    }

    //后置通知
    @After("@annotation(test)")
    public void afterTest(JoinPoint point, CustomAnnotation test) {
        System.out.println("----order=2--------afterTest:" + test.name());
    }
}
